// Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
// This source file is part of the Cangjie project, licensed under Apache-2.0
// with Runtime Library Exception.
//
// See https://cangjie-lang.cn/pages/LICENSE for license information.

#ifndef CANGJIE_MIGRATOR_RULES_CALLEXPR_MATCH_RULE
#define CANGJIE_MIGRATOR_RULES_CALLEXPR_MATCH_RULE

#include <memory>
#include <vector>
#include <string>

#include "cangjie/AST/Node.h"

#include "Actions/Action.h"
#include "TomlFile.h"
#include "ExtractedInfo.h"
#include "MatchRule.h"

namespace CangjieMigrator::Rules {

class CallExprMatchRule : public MatchRule {
public:
    CallExprMatchRule(std::string elementName, std::string funcType, std::string funcName);

    [[nodiscard]] Type GetType() const override;

    static std::unique_ptr<ExtractedInfo> ExtractInfo(const Cangjie::AST::Node &node, const PositionRange &range);

    bool MatchConditions(const ExtractedInfo *info) override;

    std::vector<Actions::Action> GenerateAction(UpdateInstance::File &file, const ExtractedInfo &info,
        const std::string &update, const Rule *rule) const override;

    static std::unique_ptr<MatchRule> TryBuild(const TomlConfig &config);

private:
    std::string elementName;
    std::string funcType;
    std::string funcName;
};

} // namespace CangjieMigrator::Rules

#endif // CANGJIE_MIGRATOR_RULES_CALLEXPR_MATCH_RULE